package com.ishow.noah.modules.service.cycle

import android.app.Service
import android.content.Intent
import android.os.Binder
import android.os.IBinder
import com.ishow.common.utils.ToastUtils
import com.ishow.common.widget.PrintView

/**
 * Created by yuhaiyang on 2019-11-08.
 *
 */
class CycleTestService : Service() {
    override fun onBind(intent: Intent?): IBinder? {
        PrintView.print("CycleTestService, onBind: ")
        return TestBinder()
    }

    override fun onRebind(intent: Intent?) {
        super.onRebind(intent)
        PrintView.print("CycleTestService, onRebind: ")
    }

    override fun onCreate() {
        super.onCreate()
        PrintView.print("CycleTestService, onCreate: ")
    }

    override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
        PrintView.print("CycleTestService, onStartCommand: ")
        return super.onStartCommand(intent, flags, startId)
    }

    override fun onDestroy() {
        PrintView.print("CycleTestService, onDestroy: ")
        super.onDestroy()
    }

    fun test() {
        PrintView.print("CycleTestService, test: ")
        ToastUtils.show(this, "Test-------")
    }

    inner class TestBinder : Binder() {

        val service: CycleTestService = this@CycleTestService
    }

}